package com.niji.littly_donkey_android.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.StrictMode;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.makeramen.roundedimageview.RoundedImageView;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.bean.Comment;
import com.niji.littly_donkey_android.bean.Fans;
import com.niji.littly_donkey_android.util.BitMapUtil;
import com.niji.littly_donkey_android.util.CirclePhotoUtil;
import com.niji.littly_donkey_android.util.NetworkGlideImageLoader;
import com.niji.littly_donkey_android.view.CircleImageView;
import com.niji.littly_donkey_android.view.StarRatingView;

import java.util.ArrayList;

public class FansAdapter extends ArrayAdapter<Fans> {


    private static final String TAG = "FansAdapter";

    private Context context;

    public FansAdapter(Context context, ArrayList<Fans> members)
    {
        super(context,0, members);
        this.context = context;
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Fans fans = getItem(position);

        if(convertView == null)
        {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_fans, parent, false);
        }

        CircleImageView roundedImageView = convertView.findViewById(R.id.fans_head);
        TextView fansName = convertView.findViewById(R.id.fans_name);
        TextView fansMessage = convertView.findViewById(R.id.fans_message);
        Button fansBtn = convertView.findViewById(R.id.fans_btn);
        TextView fansId = convertView.findViewById(R.id.fans_id);
        //thumb.setImageBitmap(BitMap.getInstance().returnBitMap(u.getThumb()));

        NetworkGlideImageLoader.getInstance().displayImage((Activity) context,fans.getHead(),roundedImageView,0,0);
        fansName.setText(fans.getName());
        fansMessage.setText(fans.getMessage());
        fansId.setText("" + fans.getId());
        fansBtn.setText(fans.getBtn());
        if (fans.getBtn().equals("关注")){
            fansBtn.setBackground(convertView.getResources().getDrawable(R.drawable.pre_submit));
            fansBtn.setTextColor(Color.parseColor("#ffffff"));
        }else{
            fansBtn.setBackground(convertView.getResources().getDrawable(R.drawable.his_home_follow_bj));
            fansBtn.setTextColor(Color.parseColor("#4258D0"));
        }
        return convertView;
    }

}



